
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>适配器模式 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sidebar-style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="责任链模式.html" />
    
    
    <link rel="prev" href="原型模式.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">基础篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../java基础/IO流基础.html">
            
                <a href="../java基础/IO流基础.html">
            
                    
                    IO流基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../java基础/集合.html">
            
                <a href="../java基础/集合.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../java基础/异常处理.html">
            
                <a href="../java基础/异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../java基础/线程.html">
            
                <a href="../java基础/线程.html">
            
                    
                    线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../java基础/网络编程.html">
            
                <a href="../java基础/网络编程.html">
            
                    
                    网络编程
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="MySQL.html">
            
                <a href="MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="Oracle.html">
            
                <a href="Oracle.html">
            
                    
                    Oracle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="Redis.html">
            
                <a href="Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="Netty.html">
            
                <a href="Netty.html">
            
                    
                    Netty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="Spring.html">
            
                <a href="Spring.html">
            
                    
                    Spring
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="SpringMVC.html">
            
                <a href="SpringMVC.html">
            
                    
                    SpringMVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="单元测试.html">
            
                <a href="单元测试.html">
            
                    
                    SpringBoot单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="设计模式.html">
            
                <a href="设计模式.html">
            
                    
                    二十三个设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="工厂模式.html">
            
                <a href="工厂模式.html">
            
                    
                    工厂模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="单例模式.html">
            
                <a href="单例模式.html">
            
                    
                    单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.3" data-path="建造者模式.html">
            
                <a href="建造者模式.html">
            
                    
                    建造者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.4" data-path="原型模式.html">
            
                <a href="原型模式.html">
            
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.8.5" data-path="适配器模式.html">
            
                <a href="适配器模式.html">
            
                    
                    适配器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.6" data-path="责任链模式.html">
            
                <a href="责任链模式.html">
            
                    
                    责任链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.7" data-path="桥接模式.html">
            
                <a href="桥接模式.html">
            
                    
                    桥接模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">高级篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../springcloud/1.cloud架构选型.html">
            
                <a href="../springcloud/1.cloud架构选型.html">
            
                    
                    Spring Cloud
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../springcloud/2.Provider-支付模块.html">
            
                <a href="../springcloud/2.Provider-支付模块.html">
            
                    
                    Provider-支付模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../springcloud/3.Consumer-订单模块.html">
            
                <a href="../springcloud/3.Consumer-订单模块.html">
            
                    
                    Consumer-订单模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../springcloud/4.重构-Common模块.html">
            
                <a href="../springcloud/4.重构-Common模块.html">
            
                    
                    重构-Common模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../springcloud/5.注册中心-Enreka.html">
            
                <a href="../springcloud/5.注册中心-Enreka.html">
            
                    
                    注册中心-Enreka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../springcloud/6.负载均衡-@LoadBalance.html">
            
                <a href="../springcloud/6.负载均衡-@LoadBalance.html">
            
                    
                    负载均衡-@LoadBalance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../springcloud/7.更换注册中心-Zookeeper.html">
            
                <a href="../springcloud/7.更换注册中心-Zookeeper.html">
            
                    
                    更换注册中心-Zookeeper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../springcloud/8.更换注册中心-Consul.html">
            
                <a href="../springcloud/8.更换注册中心-Consul.html">
            
                    
                    更换注册中心-Consul
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../springcloud/9.负载均衡-Ribbon.html">
            
                <a href="../springcloud/9.负载均衡-Ribbon.html">
            
                    
                    负载均衡-Ribbon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.9" data-path="../springcloud/10.服务调用-OpenFeign.html">
            
                <a href="../springcloud/10.服务调用-OpenFeign.html">
            
                    
                    服务调用-OpenFeign
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.10" data-path="../springcloud/11.熔断器-Hystrix.html">
            
                <a href="../springcloud/11.熔断器-Hystrix.html">
            
                    
                    熔断器-Hystrix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.11" data-path="../springcloud/12.网关-Gateway.html">
            
                <a href="../springcloud/12.网关-Gateway.html">
            
                    
                    网关-Gateway
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.12" data-path="../springcloud/13.配置中心-Config.html">
            
                <a href="../springcloud/13.配置中心-Config.html">
            
                    
                    配置中心-Config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.13" data-path="../springcloud/14.消息总线-bus.html">
            
                <a href="../springcloud/14.消息总线-bus.html">
            
                    
                    消息总线-Bus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.14" data-path="../springcloud/15.消息驱动-stream.html">
            
                <a href="../springcloud/15.消息驱动-stream.html">
            
                    
                    消息驱动-Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.15" data-path="../springcloud/16.链路监控-Sleuth.html">
            
                <a href="../springcloud/16.链路监控-Sleuth.html">
            
                    
                    链路监控-Sleuth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.16" data-path="../springcloud/17.注册中心&配置中心-nacos.html">
            
                <a href="../springcloud/17.注册中心&配置中心-nacos.html">
            
                    
                    注册中心&配置中心-nacos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.17" data-path="../springcloud/18.限流-sentinel.html">
            
                <a href="../springcloud/18.限流-sentinel.html">
            
                    
                    限流-sentinel
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../java高级/JUC.html">
            
                <a href="../java高级/JUC.html">
            
                    
                    神秘的JUC包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../java高级/Docker.html">
            
                <a href="../java高级/Docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../java高级/布隆过滤器.html">
            
                <a href="../java高级/布隆过滤器.html">
            
                    
                    布隆过滤器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../java高级/Redission.html">
            
                <a href="../java高级/Redission.html">
            
                    
                    Redission
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../java高级/MQ.html">
            
                <a href="../java高级/MQ.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="../java高级/JVM.html">
            
                <a href="../java高级/JVM.html">
            
                    
                    JVM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="../java书籍/《Effective Java》读书笔记.html">
            
                <a href="../java书籍/《Effective Java》读书笔记.html">
            
                    
                    《Effective Java》读书笔记 
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.8.1" data-path="../java书籍/创建和销毁对象.html">
            
                <a href="../java书籍/创建和销毁对象.html">
            
                    
                    创建和销毁对象
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">番外篇</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../java面试/面试题.html">
            
                <a href="../java面试/面试题.html">
            
                    
                    面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../番外篇/小程序.html">
            
                <a href="../番外篇/小程序.html">
            
                    
                    微信小程序
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >适配器模式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p><strong>&#x4E3B;&#x8981;&#x89E3;&#x51B3;&#xFF1A;</strong>&#x4E3B;&#x8981;&#x89E3;&#x51B3;&#x5728;&#x8F6F;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E2D;&#xFF0C;&#x5E38;&#x5E38;&#x8981;&#x5C06;&#x4E00;&#x4E9B;&quot;&#x73B0;&#x5B58;&#x7684;&#x5BF9;&#x8C61;&quot;&#x653E;&#x5230;&#x65B0;&#x7684;&#x73AF;&#x5883;&#x4E2D;&#xFF0C;&#x800C;&#x65B0;&#x73AF;&#x5883;&#x8981;&#x6C42;&#x7684;&#x63A5;&#x53E3;&#x662F;&#x73B0;&#x5BF9;&#x8C61;&#x4E0D;&#x80FD;&#x6EE1;&#x8DB3;&#x7684;&#x3002;</p>
<p><strong>&#x4F55;&#x65F6;&#x4F7F;&#x7528;&#xFF1A;</strong> 1&#x3001;&#x7CFB;&#x7EDF;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x73B0;&#x6709;&#x7684;&#x7C7B;&#xFF0C;&#x800C;&#x6B64;&#x7C7B;&#x7684;&#x63A5;&#x53E3;&#x4E0D;&#x7B26;&#x5408;&#x7CFB;&#x7EDF;&#x7684;&#x9700;&#x8981;&#x3002; 2&#x3001;&#x60F3;&#x8981;&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;&#x53EF;&#x4EE5;&#x91CD;&#x590D;&#x4F7F;&#x7528;&#x7684;&#x7C7B;&#xFF0C;&#x7528;&#x4E8E;&#x4E0E;&#x4E00;&#x4E9B;&#x5F7C;&#x6B64;&#x4E4B;&#x95F4;&#x6CA1;&#x6709;&#x592A;&#x5927;&#x5173;&#x8054;&#x7684;&#x4E00;&#x4E9B;&#x7C7B;&#xFF0C;&#x5305;&#x62EC;&#x4E00;&#x4E9B;&#x53EF;&#x80FD;&#x5728;&#x5C06;&#x6765;&#x5F15;&#x8FDB;&#x7684;&#x7C7B;&#x4E00;&#x8D77;&#x5DE5;&#x4F5C;&#xFF0C;&#x8FD9;&#x4E9B;&#x6E90;&#x7C7B;&#x4E0D;&#x4E00;&#x5B9A;&#x6709;&#x4E00;&#x81F4;&#x7684;&#x63A5;&#x53E3;&#x3002; 3&#x3001;&#x901A;&#x8FC7;&#x63A5;&#x53E3;&#x8F6C;&#x6362;&#xFF0C;&#x5C06;&#x4E00;&#x4E2A;&#x7C7B;&#x63D2;&#x5165;&#x53E6;&#x4E00;&#x4E2A;&#x7C7B;&#x7CFB;&#x4E2D;&#x3002;&#xFF08;&#x6BD4;&#x5982;&#x8001;&#x864E;&#x548C;&#x98DE;&#x79BD;&#xFF0C;&#x73B0;&#x5728;&#x591A;&#x4E86;&#x4E00;&#x4E2A;&#x98DE;&#x864E;&#xFF0C;&#x5728;&#x4E0D;&#x589E;&#x52A0;&#x5B9E;&#x4F53;&#x7684;&#x9700;&#x6C42;&#x4E0B;&#xFF0C;&#x589E;&#x52A0;&#x4E00;&#x4E2A;&#x9002;&#x914D;&#x5668;&#xFF0C;&#x5728;&#x91CC;&#x9762;&#x5305;&#x5BB9;&#x4E00;&#x4E2A;&#x864E;&#x5BF9;&#x8C61;&#xFF0C;&#x5B9E;&#x73B0;&#x98DE;&#x7684;&#x63A5;&#x53E3;&#x3002;&#xFF09;</p>
<p><strong>&#x5982;&#x4F55;&#x89E3;&#x51B3;&#xFF1A;</strong>&#x7EE7;&#x627F;&#x6216;&#x4F9D;&#x8D56;&#xFF08;&#x63A8;&#x8350;&#xFF09;&#x3002;</p>
<p><strong>&#x5173;&#x952E;&#x4EE3;&#x7801;&#xFF1A;</strong>&#x9002;&#x914D;&#x5668;&#x7EE7;&#x627F;&#x6216;&#x4F9D;&#x8D56;&#x5DF2;&#x6709;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x5B9E;&#x73B0;&#x60F3;&#x8981;&#x7684;&#x76EE;&#x6807;&#x63A5;&#x53E3;&#x3002;</p>
<p><strong>&#x5E94;&#x7528;&#x5B9E;&#x4F8B;&#xFF1A;</strong> 1&#x3001;&#x7F8E;&#x56FD;&#x7535;&#x5668; 110V&#xFF0C;&#x4E2D;&#x56FD; 220V&#xFF0C;&#x5C31;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x9002;&#x914D;&#x5668;&#x5C06; 110V &#x8F6C;&#x5316;&#x4E3A; 220V&#x3002; 2&#x3001;JAVA JDK 1.1 &#x63D0;&#x4F9B;&#x4E86; Enumeration &#x63A5;&#x53E3;&#xFF0C;&#x800C;&#x5728; 1.2 &#x4E2D;&#x63D0;&#x4F9B;&#x4E86; Iterator &#x63A5;&#x53E3;&#xFF0C;&#x60F3;&#x8981;&#x4F7F;&#x7528; 1.2 &#x7684; JDK&#xFF0C;&#x5219;&#x8981;&#x5C06;&#x4EE5;&#x524D;&#x7CFB;&#x7EDF;&#x7684; Enumeration &#x63A5;&#x53E3;&#x8F6C;&#x5316;&#x4E3A; Iterator &#x63A5;&#x53E3;&#xFF0C;&#x8FD9;&#x65F6;&#x5C31;&#x9700;&#x8981;&#x9002;&#x914D;&#x5668;&#x6A21;&#x5F0F;&#x3002; 3&#x3001;&#x5728; LINUX &#x4E0A;&#x8FD0;&#x884C; WINDOWS &#x7A0B;&#x5E8F;&#x3002; 4&#x3001;JAVA &#x4E2D;&#x7684; jdbc&#x3002;</p>
<p><strong>&#x4F18;&#x70B9;&#xFF1A;</strong> 1&#x3001;&#x53EF;&#x4EE5;&#x8BA9;&#x4EFB;&#x4F55;&#x4E24;&#x4E2A;&#x6CA1;&#x6709;&#x5173;&#x8054;&#x7684;&#x7C7B;&#x4E00;&#x8D77;&#x8FD0;&#x884C;&#x3002; 2&#x3001;&#x63D0;&#x9AD8;&#x4E86;&#x7C7B;&#x7684;&#x590D;&#x7528;&#x3002; 3&#x3001;&#x589E;&#x52A0;&#x4E86;&#x7C7B;&#x7684;&#x900F;&#x660E;&#x5EA6;&#x3002; 4&#x3001;&#x7075;&#x6D3B;&#x6027;&#x597D;&#x3002;</p>
<p><strong>&#x7F3A;&#x70B9;&#xFF1A;</strong> 1&#x3001;&#x8FC7;&#x591A;&#x5730;&#x4F7F;&#x7528;&#x9002;&#x914D;&#x5668;&#xFF0C;&#x4F1A;&#x8BA9;&#x7CFB;&#x7EDF;&#x975E;&#x5E38;&#x96F6;&#x4E71;&#xFF0C;&#x4E0D;&#x6613;&#x6574;&#x4F53;&#x8FDB;&#x884C;&#x628A;&#x63E1;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x660E;&#x660E;&#x770B;&#x5230;&#x8C03;&#x7528;&#x7684;&#x662F; A &#x63A5;&#x53E3;&#xFF0C;&#x5176;&#x5B9E;&#x5185;&#x90E8;&#x88AB;&#x9002;&#x914D;&#x6210;&#x4E86; B &#x63A5;&#x53E3;&#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x4E00;&#x4E2A;&#x7CFB;&#x7EDF;&#x5982;&#x679C;&#x592A;&#x591A;&#x51FA;&#x73B0;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x65E0;&#x5F02;&#x4E8E;&#x4E00;&#x573A;&#x707E;&#x96BE;&#x3002;&#x56E0;&#x6B64;&#x5982;&#x679C;&#x4E0D;&#x662F;&#x5F88;&#x6709;&#x5FC5;&#x8981;&#xFF0C;&#x53EF;&#x4EE5;&#x4E0D;&#x4F7F;&#x7528;&#x9002;&#x914D;&#x5668;&#xFF0C;&#x800C;&#x662F;&#x76F4;&#x63A5;&#x5BF9;&#x7CFB;&#x7EDF;&#x8FDB;&#x884C;&#x91CD;&#x6784;&#x3002; 2.&#x7531;&#x4E8E; JAVA &#x81F3;&#x591A;&#x7EE7;&#x627F;&#x4E00;&#x4E2A;&#x7C7B;&#xFF0C;&#x6240;&#x4EE5;&#x81F3;&#x591A;&#x53EA;&#x80FD;&#x9002;&#x914D;&#x4E00;&#x4E2A;&#x9002;&#x914D;&#x8005;&#x7C7B;&#xFF0C;&#x800C;&#x4E14;&#x76EE;&#x6807;&#x7C7B;&#x5FC5;&#x987B;&#x662F;&#x62BD;&#x8C61;&#x7C7B;&#x3002;</p>
<p><strong>&#x9002;&#x914D;&#x5668;&#x6A21;&#x5F0F;&#x6709;&#x4E09;&#x79CD;&#x89D2;&#x8272;&#xFF1A;</strong>&#x76EE;&#x6807;&#x7C7B;&#x3001;&#x6E90;&#x7C7B;&#x3001;&#x9002;&#x914D;&#x5668;&#x7C7B;</p>
<p><strong>&#x5BF9;&#x5E94;&#x73B0;&#x5B9E;&#x4E2D;&#x9002;&#x914D;&#x5668;&#xFF1A;</strong>&#x4E09;&#x5B54;&#x63D2;&#x5EA7;&#xFF08;&#x76EE;&#x6807;&#x7C7B;&#xFF09;&#x3001;&#x4E24;&#x811A;&#x63D2;&#x5934;&#xFF08;&#x6E90;&#x7C7B;&#xFF09;&#x3001;&#x8F6C;&#x6362;&#x5668;&#xFF08;&#x9002;&#x914D;&#x5668;&#x7C7B;&#xFF09;</p>
<p><img src="https://tva1.sinaimg.cn/large/e6c9d24ely1h3qceptwl9j214c0laacf.jpg" alt="UML"></p>
<p><strong>&#x6E90;&#x65B9;&#x6CD5;&#xFF1A;</strong></p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">LogFactory</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">debug</span><span class="hljs-params">(String tag,String message)</span></span>;
}
</code></pre>
<p><strong>&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#xFF1A;</strong></p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">NbLogger</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">d</span><span class="hljs-params">(<span class="hljs-keyword">int</span> priority, String message, Object ... obj)</span></span>;
}

<span class="hljs-comment">//&#x5177;&#x4F53;&#x63D0;&#x4F9B;&#x65E5;&#x5FD7;&#x529F;&#x80FD;&#x7684;&#x5B9E;&#x73B0;&#x7C7B;</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">NbLoggerImp</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">NbLogger</span> </span>{
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">d</span><span class="hljs-params">(<span class="hljs-keyword">int</span> priority, String message, Object... obj)</span> </span>{
        System.out.println(String.format(<span class="hljs-string">&quot;&#x725B;&#x903C;logger&#x8BB0;&#x5F55;:%s&quot;</span>,message));
    }
}
</code></pre>
<p><strong>&#x9002;&#x914D;&#x7C7B;&#xFF1A;</strong></p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LogAdapter</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">LogFactory</span> </span>{
    <span class="hljs-keyword">private</span> NbLogger nbLogger;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">LogAdapter</span><span class="hljs-params">(NbLogger nbLogger)</span> </span>{
        <span class="hljs-keyword">this</span>.nbLogger = nbLogger;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">debug</span><span class="hljs-params">(String tag, String message)</span> </span>{
        Objects.requireNonNull(nbLogger);
        nbLogger.d(<span class="hljs-number">1</span>, message);
    }
}
</code></pre>
<p><strong>&#x5982;&#x4F55;&#x4F7F;&#x7528;&#xFF1A;</strong></p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">AdapterClient</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">recordLog</span><span class="hljs-params">()</span> </span>{
        LogFactory logFactory = <span class="hljs-keyword">new</span> LogAdapter(<span class="hljs-keyword">new</span> NbLoggerImp());
        logFactory.debug(<span class="hljs-string">&quot;Test&quot;</span>, <span class="hljs-string">&quot;&#x6211;&#x5C06;&#x4F7F;&#x7528;&#x725B;&#x903C;logger&#x6253;&#x5370;log&quot;</span>);
    }
}
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; mine 2022-2025 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2022-06-30 16:27:23
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="原型模式.html" class="navigation navigation-prev " aria-label="Previous page: 原型模式">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="责任链模式.html" class="navigation navigation-next " aria-label="Next page: 责任链模式">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"适配器模式","level":"3.8.5","depth":2,"next":{"title":"责任链模式","level":"3.8.6","depth":2,"path":"java进阶/责任链模式.md","ref":"java进阶/责任链模式.md","articles":[]},"previous":{"title":"原型模式","level":"3.8.4","depth":2,"path":"java进阶/原型模式.md","ref":"java进阶/原型模式.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["back-to-top-button","code","splitter","expandable-chapters-small","anchors","theme-comscore","tbfed-pagefooter","sidebar-style","pageview-count","popup"],"pluginsConfig":{"sidebar-style":{"author":"梁兴龙","title":"《Java 笔记本》"},"tbfed-pagefooter":{"copyright":"Copyright &copy mine 2022-2025","modify_label":"文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"back-to-top-button":{},"pageview-count":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"java进阶/适配器模式.md","mtime":"2022-06-30T08:27:23.438Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-08-22T03:22:22.085Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sidebar-style/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

